package com.dd.machine.base.utils;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

/**
 * Created by xiao on 2016/4/21.
 */
public class ToastUtil {

    private static Toast toast;

    public static void showShortToast(Context context, int contentId) {
        showShortToast(context, context.getText(contentId).toString());
    }

    public static void showShortToast(Context context, String content) {
        if (content == null || content.equals(""))
            return;
        if (toast == null)
            toast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
        else
            toast.setText(content + "");
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }

    public static void showLongToast(Context context, String content) {
        if (content == null || content.equals(""))
            return;
        if (toast == null)
            toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
        else
            toast.setText(content + "");
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }


}
